package com.cl.ks.flow.handler;

import com.cl.spark.dto.SparkResult;
import com.cl.ks.flow.base.BaseFlowNodeHandler;
import com.cl.ks.flow.enums.NodeHandlerEnum;
import org.springframework.stereotype.Component;

import java.util.Map;

@Component
public class StartHandler extends BaseFlowNodeHandler {

    @Override
    public SparkResult process(BaseFlowNodeHandler.ProcessParam processParam) {
        Map<String, SparkResult> inputSparkResultList = processParam.getSparkNode().getInputSparkResultList();
        SparkResult sparkResult = new SparkResult();
        if (inputSparkResultList != null && !inputSparkResultList.values().isEmpty()) {
            return inputSparkResultList.values().stream().findFirst().get();
        }
        return sparkResult;
    }

    @Override
    public NodeHandlerEnum getType() {
        return NodeHandlerEnum.START;
    }
}
